//
//  HYBuyGameAccountCell.m
//  HaiYue
//
//  Created by skyline on 2018/1/23.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "HYBuyGameAccountCell.h"
#import "HYRoleView.h"
@interface HYBuyGameAccountCell ()
{
    CGFloat HEIGHT;
}
@property (nonatomic, strong) HYView *topLine;
@property (nonatomic, strong) HYView *line;
@property (nonatomic, strong) HYLabel *timeTitleLBL;
@property (nonatomic, strong) HYLabel *timeContentLBL;
@property (nonatomic, strong) HYLabel *moneyLBL;
@property (nonatomic, strong) HYRoleView *roleView;
@end
CGFloat const topLineHeight = 10;
CGFloat const *BuyGameAccountCellHeight = &topLineHeight;

@implementation HYBuyGameAccountCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.topLine.hidden = NO;
        self.timeTitleLBL.hidden = NO;
        self.line.hidden = NO;
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (HYView *)topLine
{
    if (!_topLine)
    {
        _topLine = [[HYView alloc] initWithColor:LINE_COLOR];
        [self addSubview:_topLine];
        [_topLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self);
            make.left.equalTo(self);
            make.right.equalTo(self);
            make.height.mas_equalTo(topLineHeight);
        }];
    }
    return _topLine;
}

- (HYLabel *)timeTitleLBL
{
    if (!_timeTitleLBL)
    {
        _timeTitleLBL = [[HYLabel alloc] initWithText:@"上架时间" textColor:TEXT_GRAY_COLOR textFont:[UIFont systemFontOfSize:TipsFont]];
        [self addSubview:_timeTitleLBL];
        [_timeTitleLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.topLine.mas_bottom).with.offset(GAP / 2.0);
            make.left.equalTo(self).with.offset(GAP);
        }];
    }
    return _timeTitleLBL;
}

- (HYLabel *)timeContentLBL
{
    if (!_timeContentLBL)
    {
        _timeContentLBL = [[HYLabel alloc] initWithText:@"" textColor:TEXT_GRAY_COLOR textFont:[UIFont systemFontOfSize:TipsFont]];
        [self addSubview:_timeContentLBL];
        [_timeContentLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.timeTitleLBL);
            make.left.equalTo(self.timeTitleLBL.mas_right).with.offset(GAP / 2.0);
        }];
    }
    return _timeContentLBL;
}

- (HYLabel *)moneyLBL
{
    if (!_moneyLBL)
    {
        _moneyLBL = [[HYLabel alloc] initWithText:@"" textColor:RED_COLOR textFont:[UIFont systemFontOfSize:DefaultFont weight:UIFontWeightBold]];
        [self addSubview:_moneyLBL];
        [_moneyLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.timeTitleLBL);
            make.right.equalTo(self).with.offset(-GAP);
        }];
    }
    return _moneyLBL;
}

- (HYView *)line
{
    if (!_line)
    {
        _line = [[HYView alloc] initWithColor:LINE_COLOR];
        [self addSubview:_line];
        [_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(GAP);
            make.right.equalTo(self).with.offset(-GAP);
            make.top.equalTo(self.timeTitleLBL.mas_bottom).with.offset(GAP / 2.0);
            make.height.mas_equalTo(1.0);
        }];
    }
    return _line;
}

- (HYRoleView *)roleView
{
    if (!_roleView)
    {
       _roleView = [[HYRoleView alloc] initWithHeight:GameLogoWidth];
        [self addSubview:_roleView];
        [_roleView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.line.mas_bottom).with.offset(GAP);
            make.left.equalTo(self);
            make.right.equalTo(self);
            make.height.mas_equalTo(GameLogoWidth);
        }];
    }
    return _roleView;
}

- (void)setDict:(NSDictionary *)dict
{
    if (_dict != dict)
    {
        _dict = dict;
    }
    self.timeContentLBL.text = @"01/23 03:00";
    self.moneyLBL.text = @"¥1000.00";
    self.roleView.imageName = @"3";
    self.roleView.game = @"大话西游";
    self.roleView.area = @"区服:4";
    self.roleView.tips = @"首服一区，战士号pk最佳选择";
    HEIGHT  = GameLogoWidth + GAP * 4 + _timeTitleLBL.bounds.size.height + 1.0;
    BuyGameAccountCellHeight = &HEIGHT;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
